package cn.bs.busuo.front.account.dao.persist.repository.impl;

import cn.bs.busuo.front.account.dao.persist.mapper.GoodFavoriteMapper;
import cn.bs.busuo.front.account.dao.persist.mapper.HotelFavoriteMapper;
import cn.bs.busuo.front.account.dao.persist.mapper.SightFavoriteMapper;
import cn.bs.busuo.front.account.dao.persist.repository.IFavoriteRepository;
import cn.bs.busuo.front.account.pojo.entity.GoodFavorite;
import cn.bs.busuo.front.account.pojo.entity.HotelFavorite;
import cn.bs.busuo.front.account.pojo.entity.SightFavorite;
import cn.bs.busuo.front.account.pojo.vo.FavoriteGoodVO;
import cn.bs.busuo.front.account.pojo.vo.FavoriteHotelVO;
import cn.bs.busuo.front.account.pojo.vo.FavoriteSightVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class FavoriteRepositoryImpl implements IFavoriteRepository {

    @Autowired
    private HotelFavoriteMapper hotelFavoriteMapper;
    @Autowired
    private SightFavoriteMapper sightFavoriteMapper;
    @Autowired
    private GoodFavoriteMapper goodFavoriteMapper;

    @Override
    public int selectFavoriteHotelIfExits(Long hotelId, Long id) {
        return hotelFavoriteMapper.selectFavoriteHotelIfExits(hotelId,id);
    }

    @Override
    public int addFavoriteHotel(HotelFavorite hotelFavorite) {
        return hotelFavoriteMapper.insert(hotelFavorite);
    }

    @Override
    public int deleteFavoriteHotel(Long hotelId, Long id) {
        return hotelFavoriteMapper.deleteByUserIdAndHotelId(hotelId,id);
    }

    @Override
    public List<FavoriteHotelVO> selectFavoriteHotel(Long id) {
        return hotelFavoriteMapper.listFavoriteHotel(id);
    }

    @Override
    public int selectFavoriteSightIfExits(Long sightId, Long id) {
        return sightFavoriteMapper.selectFavoriteSightIfExits(sightId,id);
    }

    @Override
    public int addFavoriteSight(SightFavorite sightFavorite) {
        return sightFavoriteMapper.insert(sightFavorite);
    }

    @Override
    public List<FavoriteSightVO> selectFavoriteSight(Long id) {
        return sightFavoriteMapper.listFavoriteSight(id);
    }

    @Override
    public int deleteFavoriteSight(Long sightId, Long id) {
        return sightFavoriteMapper.deleteByUserIdAndSightId(sightId,id);
    }

    @Override
    public int selectFavoriteGoodIfExits(Long goodId, Long id) {
        return goodFavoriteMapper.selectFavoriteGoodIfExits(goodId,id);
    }

    @Override
    public int addFavoriteGood(GoodFavorite goodFavorite) {
        return goodFavoriteMapper.insert(goodFavorite);
    }

    @Override
    public List<FavoriteGoodVO> selectFavoriteGood(Long id) {
        return goodFavoriteMapper.listFavoriteGood(id);
    }

    @Override
    public int deleteFavoriteGood(Long goodId, Long id) {
        return goodFavoriteMapper.deleteByUserIdAndGoodId(goodId,id);
    }
}
